package com.example.zhu.mapper;

import com.example.zhu.entity.Order;
import com.example.zhu.entity.OrderCount;
import com.example.zhu.entity.OrderCountDetail;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderCountMapper {

    @Select("select * from orders_count_detail where order_id = #{id}")
    List<OrderCount> selectByOrderId(Integer id);

    @Insert("insert into orders_count_detail (take_code, order_id, take_status,server_remark,helper_remark) values (#{takeCode},#{orderId},#{takeStatus},#{serverRemark},#{helperRemark})")
    void insert(OrderCount orderCount);

    @Delete("delete from orders_count_detail where order_id = #{id}")
    void deleteByOrderId(Integer id);

    @Select("select * from orders_count_detail where id = #{id}")
    OrderCount selectById(Integer id);


    @Update("update orders_count_detail set take_status=#{i} where id = #{id}")
    void update(Integer id, int i);

    @Update("update orders_count_detail set take_code=#{takeCode},take_status=#{takeStatus},helper_remark=#{helperRemark},server_remark=#{serverRemark} where id = #{id}")
    void updateOrderCount(OrderCount orderCount);

    @Delete("delete from orders_count_detail where id=#{a}")
    void deleteById(Long a);

    @Update("update orders_count_detail set  helper_remark = #{helperRemark} where id = #{id}")
    void updateHR(Integer id, String helperRemark);

    @Select("select * from orders_count_detail where order_id = #{id1} and take_status=3")
    List<OrderCount> selectEffective(Long id1);

    @Select("select t1.number ,t2.take_code from orders t1, orders_count_detail t2 where t1.id <> #{id} and t1.id = t2.order_id and left(t1.expect_time,5) = #{dateStr}")
    List<OrderCountDetail> selectAllCounts(String dateStr, Integer id);

    @Select("select id, take_code, order_id, take_status, server_remark, helper_remark from orders_count_detail where order_id = #{id}")
    List<OrderCount> selectCodes(long id);

    List<Order> selectCodes_(List<Long> idList);
}
